import { Button, message, Row, Col, Card, Form, InputNumber } from 'antd';
import React from 'react';
import { PageContainer } from '@ant-design/pro-layout';
import { queryList } from './service'

const TableList: React.FC<{}> = () => {

  const [form] = Form.useForm();
  const onFinish = () => {
    const param: any = form.getFieldsValue();

    if (!param.activityId) {
      message.error('课程ID不能为空')
      return
    }
    queryList({
      activityId:param.activityId,
      pageSize:0,
      pageNum:10
    }).then(res=>{
      if(res.status === 200){
        window.open(`/web/teacher-admin/learn/learn-detail?activityId=${param.activityId}`)
      } else {
        message.error(res.msg)
      }
    })
  }

  return (
    <PageContainer>
      <Card style={{'marginBottom':'0'}}>
        <Form form={form} onFinish={onFinish} >
          <Row gutter={[16,16]} >
            <Col span={8} >
              <Form.Item
                name="activityId"
                label="课程ID"
                >
                <InputNumber placeholder="请输入" min={0} style={{ width: '100%' }}/>
              </Form.Item>
            </Col>
            <Col span={8}>
              <Form.Item style={{textAlign: 'right'}}>
                <Button type="primary" htmlType="submit" style={{marginRight:'10px'} }>
                  查询
                </Button>
              </Form.Item>
            </Col>
          </Row>
        </Form>
      </Card>
    </PageContainer>
  );
};

export default TableList;
